<?php
header('Content-Type:application/json;charset=UTF-8');
$conn = mysqli_connect('localhost', 'root', 'root', 'project');
if (!$conn) {
    echo json_encode(['code' => 0, 'msg' => '数据库连接失败']);
}
$sql1 = "select count(*) as num1 from employee where salary between 1000 and 3000";
$sql2 = "select count(*) as num2 from employee where salary between 3000 and 5000";
$sql3 = "select count(*) as num3 from employee where salary > 5000";
$query1 = mysqli_query($conn, $sql1);
$query2 = mysqli_query($conn, $sql2);
$query3 = mysqli_query($conn, $sql3);
$result1 = mysqli_fetch_assoc($query1);
$result2 = mysqli_fetch_assoc($query2);
$result3 = mysqli_fetch_assoc($query3);
    $data = [
        ['value'=>$result1['num1'],'name'=>"薪资在1000~3000"],
        ['value'=>$result2['num2'],'name'=>"薪资在3000~5000"],
        ['value'=>$result3['num3'],'name'=>"薪资高于5000"],
    ];
echo json_encode(['code' => 1, 'msg' => '员工薪资比例', 'data' => $data]);